#!/bin/bash

echo "🚀 翼支付脚本快速配置脚本"
echo "=================================="

cd /ql

# 检查文件是否存在
if [ ! -f "scripts/yifupay/yifupay_jindou_exchange_enhanced.js" ]; then
    echo "❌ 脚本文件未找到，请先完成部署"
    exit 1
fi

# 创建配置文件
echo "📝 创建配置文件..."
cp config/yifupay/environment_variables_example.env config/yifupay/.env

# 检查依赖
echo "📦 检查依赖安装..."
if npm list node-fetch >/dev/null 2>&1; then
    echo "✅ node-fetch 已安装"
else
    echo "⚠️  正在安装 node-fetch..."
    npm install node-fetch@2
fi

echo ""
echo "📋 当前文件状态："
echo "脚本文件: $(ls -la scripts/yifupay/yifupay_jindou_exchange_enhanced.js)"
echo "配置文件: $(ls -la config/yifupay/.env)"
echo ""

# 询问用户配置
echo "🔧 请编辑配置文件填入您的信息："
echo "命令: nano config/yifupay/.env"
echo ""
echo "配置完成后，请运行测试命令："
echo "source config/yifupay/.env && node scripts/yifupay/yifupay_jindou_exchange_enhanced.js"
echo ""
echo "📅 青龙面板定时任务设置："
echo "任务名称: 翼支付金豆兑换"
echo "任务命令: node /ql/scripts/yifupay/yifupay_jindou_exchange_enhanced.js"
echo "定时规则: 0 0 * * *"
echo ""
echo "✅ 配置完成！请按照上述说明继续配置。"